//
//  HSYBaseTableModel.m
//  高仿暴走斗图
//
//  Created by huangsongyao on 16/3/4.
//  Copyright © 2016年 huangsongyao. All rights reserved.
//

#import "HSYBaseTableModel.h"
#import "NetWorkingManager+Config.h"

@implementation HSYBaseTableModel

- (instancetype)init {
    
    if (self = [super init]) {
        
        
    }
    return self;
}

- (void)firstPage {
    
    [self updateWithMergeAction:@selector(mergeRequestByUpdateUI:firstPageData:) andSignals:@[[self getContentData], [self getFirstPageData]]];
}

- (RACSignal *)getContentData {
    
//    @weakify(self);
    return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
       
        
        return nil;
    }];
}

- (RACSignal *)getFirstPageData {
    
    @weakify(self);
    return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
        
        @strongify(self);
        [[[self updateWithPage:0] deliverOn:[RACScheduler mainThreadScheduler]] subscribeNext:^(id x) {
            [subscriber sendNext:x];
            [subscriber sendCompleted];
        }];
        return nil;
    }];
}

- (void)mergeRequestByUpdateUI:(id)contentData firstPageData:(id)firstData {
    
}

- (RACSignal *)updateWithPage:(NSInteger)page {
    
    return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
       
        [[[[NetWorkingManager shareInstance] getFirstPage:page] deliverOn:[RACScheduler mainThreadScheduler]] subscribeNext:^(id x) {
            
            [subscriber sendNext:x];
            [subscriber sendCompleted];
        } error:^(NSError *error) {
            [subscriber sendError:error];
        }];
        return [RACDisposable disposableWithBlock:^{
            
        }];
    }];
}

@end
